{extend name="base" /}
{block name="main"}


<body>
<div class="fly-panel fly-panel-user">
    <div class="tpt—admin">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>修改评论</legend>
        </fieldset>

        <form class="layui-form">
            <input type="hidden" name="id" value="{$tptc.id}">

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">评论内容</label>
                <div class="layui-input-block">
                    <textarea id="textarea" name="content" required lay-verify="content"
                              style="height:500px;width: 100%;">{$tptc.content}</textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="comment_edit">立即提交</button>
                    <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
                </div>
            </div>

        </form>
    </div>
</div>

<script>
    layui.use('form', function () {
        var form = layui.form,
            jq = layui.jquery;

        form.verify({
            content: function (value) {
                if (value.replace(/<[^<>]+?>|[ ]|[&nbsp;]/g, '') == '') {
                    return '内容不得为空';
                }
            }
        });

        form.on('submit(comment_edit)', function (data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            var param = data.field;
            jq.post('{:url("comment/edit")}', param, function (data) {
                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                        location.href = '{:url("comment/index")}';
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
                }
            });
            return false;
        });

    })
</script>

{/block}